package com.hctg.forced2sleep.dialog;

import android.content.Context;
import android.os.Bundle;
import android.text.Html;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.StringRes;

import com.actor.myandroidframework.dialog.ViewBindingDialog;
import com.actor.myandroidframework.utils.toaster.ToasterUtils;
import com.blankj.utilcode.util.SizeUtils;
import com.blankj.utilcode.util.StringUtils;
import com.hctg.forced2sleep.databinding.DialogAccessibilityOpenTipsBinding;

/**
 * description: 提示Dialog
 * company    :
 * @author    : ldf
 * date       : 2024/6/14 on 11:57
 */
public class AccessibilityOpenTipsDialog extends ViewBindingDialog<DialogAccessibilityOpenTipsBinding> {

    public int iconRes;
    private String title;
    private String content;
    private String refuse;
    private String accept;
    private View.OnClickListener acceptClickListener;

    public AccessibilityOpenTipsDialog(@NonNull Context context) {
        super(context);
        setWidthPercent(0.888888f, SizeUtils.dp2px(308f));
    }

    public AccessibilityOpenTipsDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        viewBinding.ivClose.setOnClickListener(v -> { dismiss(); });
        viewBinding.tvContent.setText(
                Html.fromHtml("【无障碍】未成功开启！，连续多次失败，可以<big><strong><font color='#F45075'>重启手机</font></strong></big>解决问题！！！")
        );
        viewBinding.tvNotice.setOnClickListener(v -> {
            ToasterUtils.warning("这个功能还没做!");
        });
        viewBinding.tvRefuse.setOnClickListener(v -> { dismiss(); });
        viewBinding.tvAccept.setOnClickListener(v -> {
            dismiss();
            if (acceptClickListener != null) acceptClickListener.onClick(v);
        });
    }

    //设置图标
    public void setIconRes(int iconRes) {
        this.iconRes = iconRes;
    }

    //设置标题
    public AccessibilityOpenTipsDialog setTitle2(@StringRes int resId) {
        this.title = StringUtils.getString(resId);
        return this;
    }

    //设置内容
    public AccessibilityOpenTipsDialog setContent(String content) {
        this.content =content;
        return this;
    }

    //设置取消按钮文字
    public void setRefuse(String refuse) {
        this.refuse = refuse;
    }

    //设置确定按钮文字
    public void setAccept(String accept) {
        this.accept = accept;
    }

    public AccessibilityOpenTipsDialog setAcceptClickListener(View.OnClickListener acceptClickListener) {
        this.acceptClickListener = acceptClickListener;
        return this;
    }
}
